﻿using System;
using System.Windows;
using System.Windows.Data;

namespace BingSpatialDataServiceExcelAddin.Views.Converters
{
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                if (value is bool)
                {
                    return (bool)value ? Visibility.Visible : Visibility.Collapsed;
                }
                else if (value is string)
                {
                    return (!string.IsNullOrWhiteSpace(value as string)) ? Visibility.Visible : Visibility.Collapsed;
                }

                return Visibility.Visible;
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
